package com.xu.design;

import com.xu.design.store.ICommodity;
import com.xu.design.store.impl.CardCommodityService;
import com.xu.design.store.impl.CouponCommodityService;
import com.xu.design.store.impl.GoodsCommodityService;

/**
 *
 * @author xudenghui
 * @create 2023-07-18 9:42
 **/
public class StoreFactory {

    public ICommodity getCommodityService(Integer commodityType){
        if (null == commodityType) return null;
        if (1 == commodityType) return new CouponCommodityService();
        if (2 == commodityType) return new GoodsCommodityService();
        if (3 == commodityType) return  new CardCommodityService();
        throw  new RuntimeException("不存在的商品服务类型");
    }
}
